<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8">
    <link rel="stylesheet" th:href="@{/common/css/sapar.css}" />
    <link rel="stylesheet" type="text/css" th:href="@{/common/css/common.css}" />
<link rel="stylesheet" type="text/css" th:href="@{/frontstatic/ticket/css/my_order.css}" />
    <script type="text/javascript" th:src="@{/common/js/jquery.js}"></script>
    <script type="text/javascript" th:src="@{/common/js/sapar.js}"></script>
    <script type="text/javascript" th:src="@{/common/js/WdatePicker.js}"></script>
<title>我的订单</title>
</head>

<body>
    <div id="saper-container">
        <div id="saper-hd"></div>
        <div id="saper-bd">
            <div class="subfiled clearfix">
                <h2>待付款订单机票订单</h2>
            </div>
            <div class="subfiled-content">
                <form name="f1" id="f1" action="?m=system&amp;c=myInfo&amp;a=updateInfo&amp;type=1" method="post">
                    <div class="search-box clearfix">
                        <div class="kv-item clearfix">
                            <label>订单号：</label>
                            <div class="kv-item-content">
                                <input type="text" placeholder="订单号">
                            </div>
                        </div>
                        <div class="kv-item clearfix">
                            <label>PNR：</label>
                            <div class="kv-item-content">
                                <input type="text" placeholder="PNR">
                            </div>
                        </div>
                        <div class="kv-item clearfix">
                            <label>乘机人：</label>
                            <div class="kv-item-content">
                                <input type="text" placeholder="乘机人">
                            </div>
                        </div>
                        <div class="kv-item clearfix">
                            <label>创建日期：</label>
                            <div class="kv-item-content time-select-wrap">
                                <div class="time-select">
                                    <input type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" placeholder="">
                                    <i class="date-icon"></i>
                                </div>
                                <span class="line">-</span>
                                <div class="time-select">
                                    <input type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" placeholder="">
                                    <i class="date-icon"></i>
                                </div>
                            </div>
                        </div>
                        <a href="javascript:;" class="sapar-btn sapar-btn-recom query-btn">查询</a>
                    </div>
                </form>
                <!--表格开始-->
                <div class="table">

                    <!--表格具体内容-->
                    <div class="table-box">
                        <table>
                            <thead>
                                <tr>
                                    <th>航班号</th>
                                    <th>起飞机场</th>
                                    <th>起飞时间</th>
                                    <th>用时</th>
                                    <th>降落时间</th>
                                    <th>降落机场</th>
                                    <th>票价</th>
                                    <th>乘机人</th>
                                    <th>联系电话</th>
                                    <th>创建时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody id="info">
<!--                                <tr>-->
<!--                                    <td><a class="blue bold" href="javascript:;">141212297794</a><p class="red bold">[促销]</p></td>-->
<!--                                    <td>HZ7T6L</td>-->
<!--                                    <td>GS7482</td>-->
<!--                                    <td>2014-12-13</td>-->
<!--                                    <td><p>阿克苏</p><p>乌鲁木齐</p></td>-->
<!--                                    <td>111</td>-->
<!--                                    <td>¥1060.0</td>-->
<!--                                    <td><p class="orange bold">6.6%</p>¥62.7</td>-->
<!--                                    <td><p class="orange bold">¥997.3</p></td>-->
<!--                                    <td>222</td>-->
<!--                                    <td><p>2014-12-12</p><p>13:35:34</p></td>-->
<!--                                    <td><a href="javascript:;">[支付]</a><a href="javascript:;">[撤销]</a></td>-->
<!--                                </tr>-->
<!--                                <tr style="background-color: #EFF6FA;">-->
<!--                                    <td><a class="blue bold" href="javascript:;">141212297794</a><p class="red bold">[促销]</p></td>-->
<!--                                    <td>HZ7T6L</td>-->
<!--                                    <td>GS7482</td>-->
<!--                                    <td>2014-12-13</td>-->
<!--                                    <td><p>阿克苏</p><p>乌鲁木齐</p></td>-->
<!--                                    <td>111</td>-->
<!--                                    <td>¥1060.0</td>-->
<!--                                    <td><p class="orange bold">6.6%</p>¥62.7</td>-->
<!--                                    <td><p class="orange bold">¥997.3</p></td>-->
<!--                                    <td>222</td>-->
<!--                                    <td><p>2014-12-12</p><p>13:35:34</p></td>-->
<!--                                    <td>&lt;!&ndash;<a href="javascript:;">[支付]</a>&ndash;&gt;<a href="javascript:;">[撤销]</a></td>-->
<!--                                </tr>-->
                            </tbody>
                        </table>
                    </div>
                </div><!--表格结束-->
            </div>
        </div>
        <div id="saper-ft"></div>
    </div>
    
</body>

<script type="text/javascript">

$('select').iSelect();

$("#info").ready(showInfo());
    function showInfo() {
        $.ajax({
            type: "POST",
            url: "/showMyTickets",
            contentType:"application/x-www-form-urlencoded;charset=UTF-8",
            success: function(data){
                var outStr = eval('('+data+')');
                var Infostr="";
                for (var i=0;i<outStr.length;i++){
                    Infostr+="<tr style=\"background-color: #EFF6FA;\">";
                    Infostr+="<td>"+outStr[i].flightNo+"</td>";
                    Infostr+="<td>"+outStr[i].start+"</td>";
                    Infostr+="<td>"+outStr[i].startTime+"</td>";
                    Infostr+="<td>"+getDuration(outStr[i].startTime,outStr[i].endTime)+"</td>";
                    Infostr+="<td>"+outStr[i].endTime+"</td>";
                    Infostr+="<td>"+outStr[i].end+"</td>";
                    Infostr+="<td><p class=\"orange bold\">"+outStr[i].price+"</p></td>";
                    Infostr+="<td>"+outStr[i].name+"</td>";
                    Infostr+="<td>"+outStr[i].phone+"</td>";
                    Infostr+="<td>"+outStr[i].createTime+"</td>";
                    Infostr+="<td><a href=\"javascript:void(0);\" onclick=\"undo(this);\" data-ticketid="+outStr[i].ticketId+" id=flight"+i+">撤销</a></td>";
                    Infostr+="</tr>";
                }
                $("#info").html(Infostr);
            }
        });
    }

    function getDuration(startTime,endTime){
        var start=new Date(startTime);
        var end=new Date(endTime);
        return (parseInt(end-start)/1000/60/60).toFixed(2);
    }

    function undo(ticket) {
        var ticketId=ticket.getAttribute("data-ticketid");
        $.ajax({
            type: "POST",
            url: "/undoTicket",
            //航班id,姓名，身份证号，电话
            data: {"ticketId":ticketId},
            contentType:"application/x-www-form-urlencoded;charset=UTF-8",
            success: function(data){
                if (data=='1'){
                    window.location.reload();
                }else{
                    alert("退票失败");
                }
            }
        });
    }


</script>
</html>